/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package aexbanner;

import java.util.Timer;
import java.util.TimerTask;




/**
 *
 * @author Administrator
 */
public class BannerController {
    
    private IEffectenbeurs beurs;
    private Timer getTimer;
    
    public BannerController()
    {
        AexBanner banner = new AexBanner();
        beurs = new MockEffectenbeurs();
        getTimer = new Timer();
        getTimer.schedule(new BannerTimerTask(beurs, banner),500,500);
        banner.setVisible(true);  
    }
    
    public static void main(String[] args){
        BannerController controller = new BannerController();
    }
    
    class BannerTimerTask extends TimerTask
    {

        private IEffectenbeurs beurs;
        private AexBanner banner;
        
        public BannerTimerTask(IEffectenbeurs beurs, AexBanner banner){
            this.beurs = beurs;
            this.banner = banner;
        }
        
        @Override
        public void run() {
            IFonds[] fondsen = beurs.getKoersen();
            String s = "";
            
            for (IFonds f : fondsen){
                s += f.getNaam()+" : " + f.getKoers()+" ";
            }
            
            banner.setKoersen(s);
        }
        
    }
}
